const { contextBridge, ipcRenderer,ipcMain } = require('electron')

contextBridge.exposeInMainWorld('electronApi', {
    selectDirectory: () => ipcRenderer.invoke('select-directory'),
    openFile: () => ipcRenderer.invoke('open-file'),
    saveFile: (data) => ipcRenderer.send('save-file', data),
    getClipboard: () => ipcRenderer.sendSync('get-clipboard'),
    setClipboard: (data) => ipcRenderer.send('set-clipboard', data),
    getAppVersion: () => ipcRenderer.sendSync('get-app-version'),
    minimizeWindow: () => ipcRenderer.send('minimize-window'),
    maximizeWindow: () => ipcRenderer.send('maximize-window'),
    restoreWindow: () => ipcRenderer.send('restore-window'),
    closeWindow: () => ipcRenderer.send('close-window'),
    getDirectoryImages: () => ipcRenderer.invoke('get-directory-images'),
    getImageJson: (path) => ipcRenderer.invoke('get-image-json', {path}),
    setImageJson: (path, json) => ipcRenderer.send('set-image-json', {path, json}),
    on: (channel, func) => {
        ipcMain.on(channel, (event, ...args) => func(...args))
    }
})
